#include "EditGoDialog.h"
#include <stdio.h>
#include <assert.h>

#define NUMBER_SIZE 10

CEditGoDlg::CEditGoDlg()
{
}

CEditGoDlg::~CEditGoDlg()
{
}

LRESULT CEditGoDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    HWND hInput = GetDlgItem(IDC_LINENO);
    ::SendMessage(hInput, EM_LIMITTEXT, NUMBER_SIZE, 0);
    ::SetFocus(hInput);
    CenterWindow (GetParent());
    bHandled = TRUE;
    return TRUE;
}

LRESULT CEditGoDlg::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    return 0;
}

LRESULT CEditGoDlg::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    char szText[NUMBER_SIZE+1];
    HWND hInput = GetDlgItem(IDC_LINENO);
    ::GetWindowText(hInput, szText, NUMBER_SIZE+1);
    if (szText[0] != '\0') {
        sscanf (szText, "%d", &m_uLineNo);
        EndDialog(IDOK);
    }
    return 0;
}

LRESULT CEditGoDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    EndDialog(IDCANCEL);
    return 0;
}
